// pages/my/prevention/prevention.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    high_count: '',
    middle_count: '',
    updated_date: '',
    high_list: [],
    loading: true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const that = this
    setTimeout(that.getRequest, 2000);
  },

  getRequest() {
    const that = this
    wx.request({
      url: 'https://apis.juhe.cn/springTravel/risk?key=0f6718476701173ff3dd4ea7ac040bd2',
      success(res) {
        console.log(res)
        that.setData({
          high_count: res.data.result.high_count,
          middle_count: res.data.result.middle_count,
          updated_date: res.data.result.updated_date.substring(0, 13),
          high_list: res.data.result.high_list,
          middle_list: res.data.result.middle_list,
          loading: false,
        })
      },
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    //显示当前页面的转发按钮
    wx.showShareMenu({
      withShareTicket: true,
      menus: ['shareAppMessage', 'shareTimeline']
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    const that = this
    setTimeout(function () {
      wx.hideNavigationBarLoading()
      wx.stopPullDownRefresh()
    }, 1000);
    that.getRequest()
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})